import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-04-10
 * Time: 14:09
 */


class Card implements Comparable<Card>{
    public int rank; // 数值
    public String suit; // 花色
    public Card(int rank, String suit) {
        this.rank = rank;
        this.suit = suit;
    }
    //ctrl + i 快速实现接口
    @Override
    public int compareTo(Card o) {
        return this.rank - o.rank;
    }

    @Override
    public String toString() {
        return "Card{" +
                "rank=" + rank +
                ", suit='" + suit + '\'' +
                '}';
    }
}

public class TestDemo {
    public static void main(String[] args) {
        PriorityQueue<Card> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(new Card(2,"♥"));
        priorityQueue.offer(new Card(1,"♥"));
        priorityQueue.offer(new Card(3,"♥"));
        System.out.println(priorityQueue);
    }
    public static void main4(String[] args) {
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        TestHeap testHeap = new TestHeap();
        testHeap.createHeap(array);
        testHeap.heapSort();
        System.out.println("========================");
    }
    public static void main3(String[] args) {
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        TestHeap testHeap = new TestHeap();
        testHeap.createHeap(array);
        testHeap.offer(80);
        System.out.println("========================");
    }
    public static void main2(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        //每放一个元素 都得保证当前的堆 是大堆 或者是小堆
        priorityQueue.offer(12);
        priorityQueue.offer(1);
        priorityQueue.offer(17);
        System.out.println(priorityQueue.peek());//从结果可以看出来我们所创建的堆是一个小堆
        System.out.println(priorityQueue.size());

    }
    public static void main1(String[] args) {
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        TestHeap testHeap = new TestHeap();
        testHeap.createHeap(array);
        System.out.println("========================");
    }
}

